package com.ruoyi.find.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.find.domain.SysSubwayLocation;
import com.ruoyi.find.service.ISysSubwayLocationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 地铁周边地点Controller
 * 
 * @author LiuWeiChen
 * @date 2025-09-11
 */
@RestController
@RequestMapping("/SubwayLocation")
public class SysSubwayLocationController extends BaseController
{
    @Autowired
    private ISysSubwayLocationService sysSubwayLocationService;

    /**
     * 查询地铁周边地点列表
     */
    @RequiresPermissions("find:SubwayLocation:list")
    @GetMapping("/list")
    public TableDataInfo list(SysSubwayLocation sysSubwayLocation)
    {
        startPage();
        List<SysSubwayLocation> list = sysSubwayLocationService.selectSysSubwayLocationList(sysSubwayLocation);
        return getDataTable(list);
    }

    /**
     * 导出地铁周边地点列表
     */
    @RequiresPermissions("find:SubwayLocation:export")
    @Log(title = "地铁周边地点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysSubwayLocation sysSubwayLocation)
    {
        List<SysSubwayLocation> list = sysSubwayLocationService.selectSysSubwayLocationList(sysSubwayLocation);
        ExcelUtil<SysSubwayLocation> util = new ExcelUtil<SysSubwayLocation>(SysSubwayLocation.class);
        util.exportExcel(response, list, "地铁周边地点数据");
    }

    /**
     * 获取地铁周边地点详细信息
     */
    @RequiresPermissions("find:SubwayLocation:query")
    @GetMapping(value = "/{locationId}")
    public AjaxResult getInfo(@PathVariable("locationId") Long locationId)
    {
        return success(sysSubwayLocationService.selectSysSubwayLocationByLocationId(locationId));
    }

    /**
     * 新增地铁周边地点
     */
    @RequiresPermissions("find:SubwayLocation:add")
    @Log(title = "地铁周边地点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysSubwayLocation sysSubwayLocation)
    {
        return toAjax(sysSubwayLocationService.insertSysSubwayLocation(sysSubwayLocation));
    }

    /**
     * 修改地铁周边地点
     */
    @RequiresPermissions("find:SubwayLocation:edit")
    @Log(title = "地铁周边地点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysSubwayLocation sysSubwayLocation)
    {
        return toAjax(sysSubwayLocationService.updateSysSubwayLocation(sysSubwayLocation));
    }

    /**
     * 删除地铁周边地点
     */
    @RequiresPermissions("find:SubwayLocation:remove")
    @Log(title = "地铁周边地点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{locationIds}")
    public AjaxResult remove(@PathVariable Long[] locationIds)
    {
        return toAjax(sysSubwayLocationService.deleteSysSubwayLocationByLocationIds(locationIds));
    }
}
